package com.lagou.service.impl;

import com.lagou.dao.AccountDao;
import com.lagou.domain.Account;
import com.lagou.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @program: spring_jdbcTemplate
 * @description:
 * @author: Mr.Wang
 * @create: 2020-12-17 09:53
 **/
@Service
public class AccountServiceImpl implements AccountService {

	@Autowired
	private AccountDao accountDao;
	public List<Account> findAll() {
		return accountDao.findAll();
	}

	public Account findById(Integer id) {
		return accountDao.findById(id);
	}

	public void addAccount(Account account) {
		accountDao.addAccount(account);
	}

	public void updateAccount(Account account) {
		accountDao.updateAccount(account);
	}

	public void deleteById(Integer id) {
		accountDao.deleteById(id);
	}

	@Transactional
	public void transfer(String outName, String inName, Double money) {
		accountDao.outMoney(outName,money);
		accountDao.inMoney(inName,money);
	}
}
